package cn.xshi.sys.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.sys.dao.SysSmsDao;
import cn.xshi.sys.form.SysSmsForm;
import cn.xshi.sys.model.SysSms;
import cn.xshi.sys.service.SysSmsService;
import org.springframework.stereotype.Service;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import javax.annotation.Resource;
/**
 * @Desc 短信配置
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysSmsServiceImpl extends BaseService implements SysSmsService {

	@Resource
	private SysSmsDao sysSmsDao;

	/**
	 * 分页
	 * @param sysSmsForm
	 * @return
	 */
	public List<SysSms> getSysSmsListByCondition(SysSmsForm sysSmsForm){
		try{
			return sysSmsDao.getSysSmsListByCondition(sysSmsForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 查询对象
	 * @param id
	 * @return
	 */
	public SysSms getSysSmsById(String id){
		try{
			return sysSmsDao.getSysSmsById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 添加
	 * @param sysSms
	 * @return
	 */
	public int addSysSms(SysSms sysSms){
		int i = 0;
		try {
			sysSms.setId(toUUID());
			sysSms.setCreateId(getCurrentAccountId());
			sysSms.setCreateTime(getDate());
			i = sysSmsDao.addSysSms(sysSms);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 修改
	 * @param sysSms
	 * @return
	 */
	public int updateSysSms(SysSms sysSms){
		int i = 0;
		try {
			sysSms.setUpdateTime(getDate());
			sysSms.setUpdateId(getCurrentAccountId());
			i = sysSmsDao.updateSysSms(sysSms);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 删除
	 * @param condition
	 * @return
	 */
	public int delSysSms(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysSmsDao.delSysSms(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}